package com.collectplus.express.home;

import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;

import com.collectplus.express.BaseActivity2;
import com.collectplus.express.R;
import com.collectplus.express.app.AppCaptureActivity;
import com.collectplus.express.app.BasePopupWindow;
import com.collectplus.express.app.Intents;
import com.collectplus.express.logic.AppCache;
import com.collectplus.express.menu.MyQRCodeActivity;
import com.shouhuobao.bhi.login.LoginActivity;

import droid.frame.umeng.UMeng;

/**
 * 首页扫码popupwindow
 *
 * @author coffee<br>
 *         2016-11-30上午11:14:10
 */
public class HomeScanPopwin extends BasePopupWindow implements OnClickListener {

    private HomeFragment fragment;
    /**
     * 补差价包裹数量
     */
    private int needPayParcels;

    public HomeScanPopwin(HomeFragment fragment, int needPayParcels) {
        super((BaseActivity2) fragment.getActivityContext(), R.style.popup_window_small2big);
        this.fragment = fragment;
        this.needPayParcels = needPayParcels;
    }

    @Override
    public void findViewById() {
        setContentView(R.layout.home_title_scan_popupwin);
        //        findViewById(R.id.home_scan_item1).setOnClickListener(this);
        findViewById(R.id.home_scan_item2).setOnClickListener(this);
        //        findViewById(R.id.home_scan_item3).setOnClickListener(this);
        findViewById(R.id.home_scan_item4).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent();
        switch (v.getId()) {
            // 下单、跳转到扫码界面
            //            case R.id.home_scan_item1:
            //                if (needPayParcels > 0) {station_get_id
            //                    fragment.showUnpayedOrder();
            //                } else {
            //                    UMeng.click(getContext(), "home_scan_onOrder_click");
            //                    intent.setClass(getContext(), SelfFormInfoActivity.class);
            //                    getContext().startActivity(intent);
            ////                    intent.putExtra("from", 1);
            ////                    getContext().startActivityForResult(intent, RequestCode.scan_bag);
            //                }
            //                dismiss();
            //                break;
            // 去驿站投递包裹
            case R.id.home_scan_item2:
                if (AppCache.isLogin() == false) {
                    intent.setClass(getContext(), LoginActivity.class);
                    fragment.startActivity(intent);
                } else {
                    UMeng.click(getContext(), "home_scan_station_click");
                    intent = new Intent();
                    intent.setClass(getContext(), AppCaptureActivity.class);
                    intent.setAction(Intents.capture_station);
                    // fragment.startActivityForResult(intent, 101);
                    fragment.startActivity(intent);
                    dismiss();
                }
                break;
            //我的二维码
            case R.id.home_scan_item4:
                if (AppCache.isLogin() == false) {
                    intent.setClass(getContext(), LoginActivity.class);
                    fragment.startActivity(intent);
                } else {
                    intent.setClass(getContext(), MyQRCodeActivity.class);
                    fragment.startActivity(intent);
                    dismiss();
                }
                break;
            default:
                break;
        }
    }

}
